<template>
	<view class="pl20 v100 pr20 overauto  bgcover no-repeat"
		:style="{ backgroundImage: 'url(' + cosImageUrl('head_bg.png',true) + ')' }">
		<view class="" :style="{'paddingTop':statusBarHeigh + 'px',}">
			<!-- #ifdef H5 -->
			<view class="h60"></view>
			<!-- #endif -->
			<view class="flex alicen pl20" :style="{'height':menuButtonInfo.height + 'px',}">
				<u-icon name="arrow-left" color="#070707" size="18" @click="goback()"></u-icon>
				<view class="w30b"></view>
				<view class=" fz30 col00 bold">专业详情</view>
			</view>
		</view>
		<view class="pb20"></view>
		<view class="pt20 pb20 pl20 pr20 bgfff col33 ius10">
			<view class="flex alicen between colb6">
				<view class="fz30 mt10 mb10">第 <text class="pt8 pb8 pl20 pr20 border1 boree">{{sffIdx}}</text>志愿
				</view>
				<view class="fz30">是否专业服从调剂</view>
				<view class="flex alicen">
					<view class="flex alicen mr10" >
						<image class="w30 h30"
							:src="deilObj.sffczytj == 0?cosImageUrl('/check.png',true):cosImageUrl('/nocheck.png',true)"
							mode="aspectFill"></image>
						<view class="fz28 ml8">服从</view>
					</view>
					<view class="flex alicen">
						<image class="w30 h30"
							:src="deilObj.sffczytj == 1?cosImageUrl('/check.png',true):cosImageUrl('/nocheck.png',true)"
							mode="aspectFill"></image>
						<view class="fz28 ml8">不服从</view>
					</view>
				</view>
			</view>

			<view class="bgfff border1 boree">
				<view class="flex alicen  fz28">
					<view class="pt20 pb20 flex1 boree flexCenter bdr1_bottom">省市:{{deilObj.province}}</view>
					<view class="pt20 pb20 flex1 boree flexCenter bdr1_bottom bdl1-left1">院校:{{deilObj.schoolName}}</view>
				</view>
				<view class="flex alicen  fz28">
					<view class="pt20 pb20 flex1 boree flexCenter bdr1_bottom">院校代码:{{deilObj.schoolCode}}</view>
					<view class="pt20 pb20 flex1 boree flexCenter bdr1_bottom bdl1-left1">全国排名:{{deilObj.qgRank}}</view>
				</view>
				<view class="flex alicen  fz28">
					<view class="pt20 pb20 flex1 boree flexCenter bdr1_bottom">专业组:{{deilObj.zyzCode}}</view>
					<view class="pt20 pb20 flex1 boree flexCenter bdr1_bottom bdl1-left1">投档概率:{{deilObj.rateSumit||'--'}}%
					</view>
				</view>
				<view class="flex alicen  fz28">
					<view class="pt20 pb20 flex1 boree flexCenter bdr1_bottom bdl1-rigth1">招生计划人数:{{deilObj.planNums}}
					</view>
					<view class=" flex1 boree flexCenter"></view>
				</view>
			</view>
		</view>
		<view class="pt20 mt20 pb20 pl20 pr20 bgfff col33 ius10" v-for="(item,index) in deillist" :key="index">
			<view class="fz28 bold col00">{{item.majorName||'--'}}</view>
			<view class="flex alicen around mt20 fz28">
				<view class="">
					<view class="">全国排名:</view>
					<view class="mt10 txtcen">{{item.majorPm||'--'}}</view>
				</view>
				<view class="">
					<view class="">招生计划数:</view>
					<view class="txtcen mt10">{{item.planNums||'--'}}</view>
				</view>
				<view class="">
					<view class="">录取概率:</view>
					<view class="txtcen mt10">{{item.rateSubmit||'--'}}%</view>
				</view>
			</view>
		</view>
		<view class="pb30"></view>
		<view class="pt20 pb20 bgff000 ius100 fz30 colff flexCenter" @click="download()">导出</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sffIdx: 0,
				deillist: [],
				deilObj: {},
				id:'',
			}
		},
		onLoad(options) {
			if (options.id&&options.index) {
				this.sffIdx = options.index
				this.id = options.id
				this.details();
			}
			
		},
		methods: {
			//下载
			async download(){
				let params = {
					userId: this.readData('useId')
				}
				let load = await this.request.get('/api/downloadMntbList',{params})
				
				if(load.code == 200){
					console.log('load',load.data.down)
					uni.downloadFile({
					  url:load.data.down,  // 文件的下载地址
					  success: (res) => {
					    if (res.statusCode === 200) {
					      // 下载成功后的处理
					      console.log('文件下载成功', res.tempFilePath);  // 下载的文件路径
						  uni.saveFile({
						    tempFilePath: res.tempFilePath,  // 下载后文件的临时路径
						    success: (saveRes) => {
						      console.log('文件保存成功', saveRes.savedFilePath);  // 保存后的文件路径
							   uni.openDocument({
							              filePath: saveRes.savedFilePath,
							              success: (openRes) => {
							                console.log('文件打开成功');
							              },
							              fail: (err) => {
							                console.error('打开文件失败', err);
							              }
							            });
							  
						    },
						    fail: (err) => {
						      console.error('保存文件失败', err);
						    }
						  });
					      // 可以进行文件的保存或其他操作
					    } else {
					      console.error('下载失败', res.statusCode);
					    }
					  },
					  fail: (err) => {
					    console.error('下载失败', err);
					  }
					});
					
				}
			},
			async details() {
				let params = {
					id: this.id,
					userId: this.readData('useId')
				}
				let deil = await this.request.get('/api/getMntbById', {
					params
				})
				if (deil.code == 200) {
					this.deilObj = deil.data.zytb
					this.deillist = deil.data.detailList
					console.log('deil', deil.data)
				}
			}
		}

	}
</script>

<style>
</style>